package com.bluestar.tools.utils;

import java.io.PrintWriter;
import java.io.StringWriter;

public class ThrowableUtils {

    public static String toString(Throwable throwable) {
        if (throwable == null) {
            return null;

        } else {
            String result = null;
            try {
                StringWriter stringWriter = new StringWriter();
                PrintWriter printWriter = new PrintWriter(stringWriter);
                throwable.printStackTrace(printWriter);

                for (Throwable cause = throwable.getCause(); cause != null; cause = cause.getCause()) {
                    cause.printStackTrace(printWriter);
                }

                result = stringWriter.toString();
                printWriter.close();
                stringWriter.close();
            } catch (Exception var5) {
                var5.printStackTrace();
            }

            return result;
        }
    }

}